package org.zhxy.zhxy.controller.front;



import org.zhxy.zhxy.entity.AppointRecord;
import org.zhxy.zhxy.entity.dto.ClassRoomAppointAddDto;
import org.zhxy.zhxy.service.AppointRecordService;
import org.springframework.web.bind.annotation.*;
import org.zhxy.zhxy.utils.Result;

import javax.annotation.Resource;
import java.util.List;

/**
 * 预约记录表(AppointRecord)表控制层
 *
 * @author yayong
 * @since 2024-10-19 20:38:17
 */
@RestController
@RequestMapping("/api/appointRecord")
public class AppointRecordController {

/**
 * 服务对象
 */
@Resource
private AppointRecordService appointRecordService;


/*
教室预约
 */
    @PostMapping("/add")
    public Result appoint(@RequestBody ClassRoomAppointAddDto classRoomAppointAddDto){
        appointRecordService.appoint(classRoomAppointAddDto);
        return Result.success();
    }

    /**
     * 条件查询我的预约申请
     */
    @GetMapping("/my-appoint")
    public Result myAppoint(String status){
     List<AppointRecord> res =    appointRecordService.selectMyAppoint(status);
     return Result.success(res);
    }

    /**
     * 取消预约
     */
    @GetMapping("/cancel")
    public Result cancel(String id){
       appointRecordService.canleAppoint(id);
        return Result.success();
    }
}

